set autoindent
set background=dark
set backspace=indent,eol,start
set cin
set enc=utf8 fencs=utf8,cp936
set fileformat=unix
set history=50
set ignorecase
set incsearch
set nobackup
set nocompatible
set noic
set noswapfile
set nowrap
set nowrapscan
set nu
set ruler
set shiftwidth=4
set showcmd
set showmatch
set softtabstop=4
set tabstop=4
set expandtab
set paste
syntax enable

let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1

map <F1> :NERDTreeToggle<CR>
map <F2> :NERDTreeMirror<CR>
map <F3> :wall<CR>
map <F4> :wqall<CR>
map <F5> :TlistToggle<CR>
let Tlist_WinWidth = 30
let Tlist_Use_Right_Window=1
let Tlist_Use_SingleClick=1
map <F8> :! ctags -R .<CR>

" fun! KeywordComplete()
    " let left = strpart(getline('.'), col('.') - 2, 1)
	" if left =~ "^$"
		" return "\<Tab>"
	" elseif left =~ ' $'
		" return "\<Tab>"
	" else
		" return "\<C-N>"
" endfun
" inoremap <silent> <Tab> <C-R>=KeywordComplete()<CR>

let mapleader=","
" Python
map <silent><leader>p :!python %<ENTER>
map <silent><leader>d :!python -m pdb %<ENTER>

" Java
" let filename=fnamemodify(bufname("%"),":t:r")
" let cwd=fnamemodify(bufname("%"),":h")
" map <silent><leader>j :!javac %<ENTER>
" map <silent><leader>r :execute ":!cd ".cwd." ; java ".filename<ENTER>

" ClosePairs
" inoremap ( ()<ESC>i
" inoremap ) <c-r>=ClosePair(')')<CR>
" inoremap [ []<ESC>i
" inoremap ] <c-r>=ClosePair(']')<CR>

" function! ClosePair(char)
" 	if getline('.')[col('.') - 1] == a:char
" 		return "\<Right>"
" 	else
" 		return a:char
" 	endif
" endf

inoremap jj <ESC>
